<script type="text/javascript">
	$(function() {
		$("#accordion").accordion({
			scollapsible: true,
			autoHeight: false,
			navigation: true
		});
	});
</script>


<div class="ui-widget">
<div style="margin-top: 20px; padding: 0pt 0.7em;"
	class="ui-state-highlight ui-corner-all">
<p><span style="float: left; margin-right: 0.3em;"
	class="ui-icon ui-icon-person"></span> <strong><?php echo lang('menuitem_patient').' '.lang('form_label_name')?> : </strong>
                <?php echo $patient_info['first_name'].' '. $patient_info['last_name'];?>
                <br>
<span style="float: left; margin-right: 0.3em;"
	class="ui-icon ui-icon-unlocked"></span> <strong><?php echo lang('menuitem_patient').' '.lang('general_code')?> :</strong>
                 <?php echo $patient_info['code']?>
            </p>
</div>
</div>

<div class="btn"><?php echo lang('form_label_contact')?></div>
<div class="btn-larg" ><?php echo lang('menuitem_medical_history')?></div>
<div class="btn" onClick="get_patient_att()"><?php echo lang('form_label_attachment')?></div>
<?php //Get the attachment ?>
<script>
function get_patient_att(){
     $('#attachment').html('<br><br><img src=<?php echo base_url ()?>images/loading.gif>');
 $.post("<?php echo site_url()?>/patient/get_attachments/<?php echo $patient_info['code']?>/1",
		function(data){
                html='	<h2>Attachment</h2><ul>';
                 for(var i in data)
                     html+='<li><a TARGET="_blank" href="<?php echo base_url ()?>AttachedData/<?php echo $patient_info['code']?>/'+data[i]+'">'+ data[i] +'</a></li>'
                     
                 html+='</ul>'

                     $('#attachment').html(html);

                    },'json');   
}

</script>
<div id="attachment"></div>

<!-- <div class="btn"><?php echo lang('general_print')?> </div> -->

<br>
<br>



<div>


<div id="accordion">
    <?php
    //Set the Counter 
    $i =$count= 0;
    $old_date=NULL;
    if(!empty($result))
    foreach ($result as $preview_date=>$preview_array)
    {
        //echo $count.'   '.$i;
    	
        $count++;
        if($count>1) {
          }
        echo "<h3><a href='#section$i'>". lang('form_label_date')." ". $preview_date."</a></h3>";
        
              
        
        echo "<div>";
        
             
         
         
               	  $atts = array(
              'width'      => '800',
              'height'     => '600',
              'scrollbars' => 'yes',
              'status'     => 'yes',
              'resizable'  => 'yes',
              'screenx'    => '0',
              'screeny'    => '0',
                      'class'=>'btn'
            );

         echo anchor_popup('patient/history_report/'.$patient_info['id'].'/'.$preview_date, lang('general_print'), $atts);
        
        
        if(!empty($preview_array['examination'])){
           echo "<p> <u>".lang('menuitem_examination')."</u><br>";
           echo "<ul>";
        
        	foreach ($preview_array['examination'] as $examination_id){
                
                 if(!empty($exam[$examination_id]))
                  echo "<li>".$exam[$examination_id]."</li>";
        	}
            
        	
        	echo "</ul>";
            echo "</p>";
        	
        
        }
        
        if(!empty($preview_array['checkup'])){
           echo "<p> <u>".lang('menuitem_checkup')."</u><br>";
           echo "<ul>";
        
        	foreach ($preview_array['checkup'] as $checkup_id){

        		
     if(!empty($check[$checkup_id]))
                  echo "<li>".$check[$checkup_id]."</li>";
        	        	}
            
        	
        	echo "</ul>";
            echo "</p>";
        	
        
        }
        if(!empty($preview_array['note']))
         echo "<p>".$preview_array['note']."</p>";
        
        	
        	echo "</div>";
         
        
    }    
        
 /*       if($old_date!==$dt['preview_date']){
        	if($count>1) echo "</div>";
        echo "<h3><a href='#section$i'>". lang('form_label_date')." ". $dt['preview_date']."</a></h3>";
        
        echo "<div>";
        }*/
        /*
         if(!empty($dt['examination_id']))
         {
            echo "<p> <u>Examination</u><br>";
                echo "<ul>";
                $exam_name=get_the_names($exam['info'] , $dt['examination_id'], 'description');
                 if(!empty($exam_name))
                  echo "<li>".$exam_name."</li>";
                echo "</ul>";
            echo "</p>";
        }
        if(!empty($dt['checkup_id']))
        {
            echo "<p> <u>Checkup</u><br>";
                echo "<ul>";
                $checkup_name=get_the_names($check['info'] , $dt['checkup_id'], 'test_name');
                 if(!empty($checkup_name))
                  echo "<li>".$checkup_name."</li>";
                echo "</ul>";
            echo "</p>";
        }
        
        echo "<p>".$dt['note']."</p>";
        
        $old_date=$dt['preview_date'];
        $i++;
    }*/
    ?>

</div>

</div>
<!-- -->
